package com.eascs.web.p2p.common.controller;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;

import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.site.controller.AfterCompletion;
import com.eascs.site.handler.PreHandler;
import com.eascs.site.view.ViewContext;
import com.eascs.web.p2p.common.interceptor.NoAccessException;

public abstract class BaseMasterViewController extends BaseViewController implements PreHandler, AfterCompletion {

	private final Logger logger = LoggerFactory.getLogger(BaseMasterViewController.class);

	@ExceptionHandler(NoAccessException.class)
	@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
	public String NoAccessException(NoAccessException ex, WebRequest request) {
		logger.warn(ex.getMessage(), ex);
		ViewContext.put("exceptionMessage", "您无权限访问该页面");
		return "/member/login";
	}

	@Override
	public void preHandle() {
	}

	@Override
	public void afterCompletion() {

	}

}